package com.buddy.sds.auth.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.buddy.sds.auth.entity.SystemDepartment;
import com.buddy.sds.common.mybatis.RedisCache;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ISystemDepartmentMapper extends BaseMapper<SystemDepartment> {

    @Select("select * from t_system_department where department_pid = #{pid}")
    List<SystemDepartment> getDepartmentListByPid(String pid);

    @Select("select exists(select department_id from t_system_department where department_id = #{did})")
    boolean idExists(String did);

    @Update("update t_system_user set user_department = null where user_department = #{did}")
    void emptyUserDep(String did);

    @Select("select * from t_system_department where department_id =#{deptId}")
    SystemDepartment getDepartmentById(String deptId);
}
